[#import "/framework/JGP.htm"  as JGP]
<!--
项目   jgp-cloud-parent
作者   LOUFEI [Gavin]
时间   2018/9/10
-->
[@JGP.head "Title"/]
[@JGP.body]
    <jgp-div _row="['40','90','*']" _runit="px">
        <div slot="1-1">
            <jgp-btn _icon="edit" _fn="addArticle">创建文章</jgp-btn>
        </div>
        <jgp-query slot="2-1" _id="articleQueryForm" _label_width="60px"
                   _action="/doc/articleApiController/queryArticle"
                   _target="articleGrid">
            <jgp-form-group _title="搜索">
                <jgp-text _label="文章名称" _name="title" _col="6" _placeholder="文章名称"></jgp-text>
                <jgp-date-time _label="开始日期" _col="3" _name="beginDate" _format="date"
                               _placeholder="开始日期"></jgp-date-time>
                <jgp-date-time _label="结束日期" _col="3" _name="endDate" _format="date"
                               _placeholder="结束日期"></jgp-date-time>
            </jgp-form-group>
        </jgp-query>
        <jgp-grid slot="3-1" _id="articleGrid" _single="true" _check="false"
                  _record_tools="[{'icon':'edit','tip':'编辑','fn':'editArticle'},
                  {'icon':'trash-o','tip':'删除','fn':'removeArticle'}]"></jgp-grid>
    </jgp-div>
[/@JGP.body]

[@JGP.foot]
    <script>
        function addArticle() {
            var dialog = {
                'title': "添加功能组",
                'width': '900px',
                'height': '700px',
                'url': '/attachment/articleController/addArticle',
                'callback': function (result) {
                    if (result)
                        window.location.reload();
                }
            };
            JGP.$dialog(dialog);
        }

        function editArticle(args) {
            var dialog = {
                'title': "添加功能组",
                'width': '900px',
                'height': '700px',
                'url': '/attachment/articleController/editArticle/'+args.back.record.id,
                'callback': function (result) {
                    if (result)
                        location.reload();
                }
            };
            JGP.$dialog(dialog);
        }
        
        function removeArticle(args) {
            JGP.$confirm('是否删除菜单:'+args.back.record.title,function () {
                JGP.$post('/attachment/articleApiController/removeArticle/'+args.back.record.id,{},function (res) {
                    if(res.flag){
                        JGP.$alert('删除成功！');
                        location.reload();
                    }
                })
            })
        }
    </script>
[/@JGP.foot]